// ServerDlg.h : header file
//

#pragma once
#include "serversocket.h"
#include "clientsocket.h"
#include "afxwin.h"
#include "Config.h"


// CServerDlg dialog
class CServerDlg : public CDialog
{
	static const int MAX_CLIENTS = 8;
// Construction
public:
	CServerDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_SERVER_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	ServerSocket m_serverSocket;
	ClientSocket m_clientSocketArr[MAX_CLIENTS];
	int m_clientIDArr[MAX_CLIENTS];
	int m_clientCounter;
	afx_msg void OnBnClickedBtnStartserver();
	int m_port;
	CString m_ipAddress;
	bool OnAccept(void);
	afx_msg void OnBnClickedBtnStopServer();
	afx_msg void OnBnClickedBtnExit();
	bool OnReceive(char* buff, int size);
	CComboBox m_cmbClientList;
	void Proccess(char* buff);
	char m_fileName[256];
	long m_fileSize;
	char m_szBuff[BUFF_SIZE];
	void SendToAll(void);
	void SendToClient(int clientID);

	byte* m_fileBuffer;

	Package m_package;
	FILE* m_file;
	int m_receiveSize;
protected:
	virtual void OnCancel();
};
